package scan;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;

//Component是"组件"的意思
//表示当前类是Spring框架的组件
// 这个类会自动实例化一个对象保存到Spring容器
// 这个对象的id就是类名首字母小写的版本
// id:hero
@Component
//@Lazy
@Scope("prototype")
public class Hero {

    private String name="后羿";
    private Integer age=18;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    @Override
    public String toString() {
        return "Hero{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}
